<?php
/*
Plugin ID: cn.usephp.uclient
Plugin Name: UCenter 整合插件
Plugin URI: http://www.usephp.cn/plugins/uclient.html
Description: 使系统与UCenter整合，完成与基于UCenter整合的其它站点的通信与同步登录功能。
Author: Leo Ning
Version: 1.0
Author URI: http://www.usephp.cn/
Option: uclient
*/
include_once dirname ( __FILE__ ) . '/uclient_hooks.php';
include_once dirname ( __FILE__ ) . '/uclient_option.php';
//添加一个路由，将对api/uc.html的请求转发给本插件处理
Router::route ( '#/api/uc\.html#', array ('plugin' => 'uclient', 'action' => 'uclient', 'last' => true ) );
//初始化 uclient的配置
function init_uclient_config() {
	static $inited = false;
	if (! $inited) {
		$inited = true;
		// 加载配置信息
		$options = get_option_uclient_option ();
		define ( 'UC_CONNECT', $options ['uc_connect'] );
		define ( 'UC_DBHOST', $options ['uc_dbhost'] );
		define ( 'UC_DBUSER', $options ['uc_dbuser'] );
		define ( 'UC_DBPW', $options ['uc_dbpw'], 'DECODE' );
		define ( 'UC_DBNAME', $options ['uc_dbname'] );
		define ( 'UC_DBTABLEPRE', $options ['uc_dbtablepre'] );
		
		define ( 'UC_KEY', $options ['uc_key'] );
		define ( 'UC_API', $options ['uc_api'] );
		define ( 'UC_IP', $options ['uc_ip'] );
		define ( 'UC_APPID', $options ['uc_appid'] );
		
		define ( 'UC_DBCONNECT', '0' );
		define ( 'UC_CHARSET', 'utf-8' );
		define ( 'UC_PPP', '20' );
		// 加载uclient api
		include_once dirname ( __FILE__ ) . '/uc_client/client.php';
	}
}

// xml序列化
function uc_xml_serialize($arr, $htmlon = 0) {
	if (! function_exists ( 'xml_serialize' )) {
		include_once dirname ( __FILE__ ) . '/uc_client/lib/xml.class.php';
	}
	return xml_serialize ( $arr, $htmlon );
}
// xml反序列化
function uc_xml_unserialize($arr, $htmlon = 0) {
	if (! function_exists ( 'xml_serialize' )) {
		include_once dirname ( __FILE__ ) . '/uc_client/lib/xml.class.php';
	}
	return xml_serialize ( $arr, $htmlon );
}